'use strict';

// SettingBlock controller,设置权限访问控制
app.controller('SettingBlockCtrl', 
['$scope', '$state','LoginService',
function($scope, $state, LoginService) {
	var vm = $scope.vm = this;
	
	var pros = ['M_LOG', 'M_ARCH','M_USER','M_ROLE','M_SYSTEMCONFIG'];
	var stae = ['setting.log', 'setting.area.list','setting.user.list','setting.role.list','setting.sysconfig'];
	var test = function(pros, staes){
		LoginService.hasPermission(pros[0]).then(function(){
			$state.go(staes[0]);
		}, function(){
			if(ISS.isNotEmpty(pros)){
				test(pros.slice(1,pros.length), staes.slice(1,staes.length));
			}
		});
	}
	
	test(pros, stae);
}])